package com.atomic.test.example.config;

import com.atomic.test.example.utils.ControllerExceptionHandler;
import com.atomic.test.example.interceptor.AuthInterceptor;
import org.springframework.aop.interceptor.PerformanceMonitorInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author dreamyao
 * @title
 * @date 2021/10/21 5:25 下午
 * @since 1.0.0
 */
@Configuration
@EnableWebMvc
public class WebConfig  implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AuthInterceptor()).addPathPatterns("/**");
    }

    @Bean
    public ControllerExceptionHandler exceptionHandler() {
        return new ControllerExceptionHandler();
    }

    @Bean
    public PerformanceMonitorInterceptor performanceMonitorInterceptor() {
        return new PerformanceMonitorInterceptor();
    }

}
